<ul class="nav nav-tabs">
	<li ng-class="{'active':pagedata.op=='list'}"><a href="javascript:;" ng-click="access('list')">自定义菜单</a></li>
	<li ng-class="{'active':pagedata.type==1}"><a href="javascript:;" ng-click="access('edit','type=1')">添加默认菜单</a></li>
	<li ng-class="{'active':pagedata.type==2}"><a href="javascript:;" ng-click="access('edit','type=2')">添加个性化菜单</a></li>
</ul>
<div class="keyword-list-head" ng-if="pagedata.op=='list'">
	<div class="keyword-list-head clearfix">
		<div class="input-group jinyun-margin-bottom" style="width:465px;">
			<input class="form-control" type="text" ng-model="pagedata.params.title" value="" placeholder="输入关键字名称" style="width: 427px;">
			<span class="input-group-btn"><button id="submit" ng-click="access('list','wechat_id='+pagedata.wechat_id)" class="btn btn-default"><i class="fa fa-search"></i></button></span>
		</div>
	</div>
</div>
<div class="clearfix" ng-if="pagedata.op=='list'">
			<table class="table jinyun-table table-hover vertical-middle jinyun-form">
				<thead class="navbar-inner">
				<tr>
					<th>标题</th>
					<th>类型</th>
					<th>创建时间</th>
					<th>是否生效</th>
					<th style="min-width:70px; width:350px" class="text-right">操作</th>
				</tr>
				</thead>
                <tr ng-repeat="item in pagedata.list">
					<td>{{item.title}}</td>
					<td>
						<span  class="label label-success">{{pagedata.menutypes[item.type]}}</span>
					</td>
					<td>{{item.createtime}}</td>
					<td>
						<span class="label {{pagedata.menu_status_style[item.status]}}">{{pagedata.statuss[item.status]}}</span>
					</td>
					<td align="right">
						<a ng-click="post({},'set','id='+item.id)" href="javascript:;" class="btn btn-default" >推送到微信端</a>
						<a ng-show="item.status==1" ng-click="post({},'del','id='+item.id,'确定要删除该菜单吗？如果该菜单为默认菜单，将会连同所有个性化菜单一起删除！')" href="javascript:;" class="btn btn-default" >从微信端删除</a>
						<a ng-click="access('edit','id='+item.id)" href="javascript:;" class="btn btn-default">编辑</a>
					</td>
				</tr>
			</table>
</div>
<div class="conditionMenu" id="conditionMenuDesigner" ng-if="pagedata.op=='edit'" ng-cloak>
<link href="../core/resource/css/app.css?v=2020" rel="stylesheet">
	<div class="app clearfix" >
		<div class="app-preview">
			<div class="app-header"></div>
			<div class="app-content">
				<div class="inner">
					<div class="title">
						<h1><span>{{pagedata.menutypes[pagedata.item.type]}}</span></h1>
					</div>
				</div>
				<div class="nav-menu">
					<div class="js-quickmenu nav-menu-wx clearfix" ng-class="{0 : 'has-nav-0', 1 : 'has-nav-1', 2: 'has-nav-2', 3: 'has-nav-3', 4 : 'has-nav-3'}[pagedata.item.button.length + 1]">
						<ul class="nav-group designer-x">
							<li class="nav-group-item js-sortable" ng-repeat="but in pagedata.item.button" ng-class="{0 : '', 1 : 'active'}[pagedata.activeItem == but ? 1 : 0 ]">
								<input type="hidden"/>
								<a href="javascript:void(0);" ng-click="pagedata.father=pagedata.item.button;pagedata.index=$index;pagedata.activeItem=but;">
									<i class="fa fa-minus-circle" ng-show="but.sub_button.length > 0"></i>
									{{but.name}}
								</a>
								<dl class="designer-y">
									<dd ng-repeat="subBut in but.sub_button"  ng-class="{0 : '', 1 : 'active'}[pagedata.activeItem == subBut ? 1 : 0 ]">
										<input type="hidden"/>
										<a href="javascript:void(0)" ng-click="pagedata.father=but.sub_button;pagedata.index=$index;pagedata.activeItem=subBut;">{{subBut.name}}</a>
									</dd>
									<dd ng-if="but.sub_button.length < 5" class="js-not-sortable">
										<a href="javascript:void(0)" ng-click="but.sub_button.push({'name':'子菜单名称'});"><i class="fa fa-plus"></i></a>
									</dd>
								</dl>
							</li>
							<li class="nav-group-item" class="js-not-sortable"ng-if="pagedata.item.button.length < 3">
								<a href="javascript:void(0);" ng-click="pagedata.item.button.push({'name':'菜单名称','sub_button':[]});" class="text-success">
									<i class="fa fa-plus"></i> 添加菜单
								</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="app-side">
			<div class="menu app-conditionMenu-edit">
				<div class="arrow-left"></div>
				<div class="inner">
					<div class="panel panel-default">
						<div class="panel-body form-horizontal">
							<div class="conditionMenu-wx">
								<div class="card">
									<div class="nav-region">
										<div class="first-nav">
											<h3>标题</h3>
											<div class="alert">
												<div class="form-group">
													<label class="control-label col-xs-2">标题</label>
													<div class="col-xs-10">
														<input type="text" class="form-control" ng-model="pagedata.item.title"/>
														<span class="help-block">仅用于区分个性化菜单</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-2">公众号</label>
													<div class="col-xs-10">
														<select class="form-control" ng-model="pagedata.item.wechat_id">
														
														<option ng-repeat="wechat in pagedata.wechats" value="{{wechat.id}}" ng-selected="wechat.id==pagedata.item.wechat_id">{{wechat.title}}</option>
														</select>
														<span class="help-block">设置该菜单应用于哪个公众号</span>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="conditionMenu-wx" ng-if="pagedata.item.type==2">
								<div class="card">
									<div class="nav-region">
										<div class="first-nav">
											<h3>匹配设置</h3>
											<div class="alert">
												<div class="form-group">
													<label class="control-label col-xs-2">性别</label>
													<div class="col-xs-10">
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.sex" value="0"  > 不限
														</label>
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.sex" value="1"  > 男
														</label>
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.sex" value="2"  > 女
														</label>
														<span class="help-block">为保护个人隐私，个性化菜单将不再支持对性别区分</span>
													</div>
												</div>
												<div class="form-group fans-group">
													<label class="control-label col-xs-2">粉丝分组</label>
													<div class="col-xs-10">
														<label class="radio-inline">
														<input type="radio"  value="-1" ng-model="pagedata.item.matchrule.group_id"/> 不限
														</label>
														<label ng-repeat="group in pagedata.groups" class="radio-inline">
														<input type="radio" value="{{group.id}}" ng-model="pagedata.item.matchrule.group_id" /> {{group.title}}
														</label>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-2">客户端</label>
													<div class="col-xs-10">
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.client_platform_type" value="0"  > 不限
														</label>
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.client_platform_type" value="1"  > IOS(苹果)
														</label>
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.client_platform_type" value="2"  > Android(安卓)
														</label>
														<label class="radio-inline">
															<input type="radio" ng-model="pagedata.item.matchrule.client_platform_type" value="3"  > Others(其他)
														</label>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-2">语言限制</label>
													<div class="col-xs-10" style="margin-top:10px">
														<select ng-model="pagedata.item.matchrule.language" class="form-control">
															<option value="" disabled>选择语言</option>
																<option ng-repeat="lan in pagedata.languages " value="{{lan.en}}">{{lan.ch}}</option>
														</select>
														<span class="help-block">为保护个人隐私，个性化菜单将不再支持对语言区分</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-2">地区限制</label>
													<div class="col-xs-10">
														<div style="margin-top:10px">
														<div class="row row-fix tpl-district-container">
															<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
																<select ng-model="pagedata.item.matchrule.province" class="form-control tpl-province">
																<option value="" selected="selected">请选择省份</option>
																<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.item.matchrule.province==value">{{value}}</option>
																</select>
															</div>
															<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
																<select ng-model="pagedata.item.matchrule.city" class="form-control tpl-city">
																<option value="" selected="selected">请选择城市</option>
																<option ng-repeat="(value,data) in pagedata.province[pagedata.item.matchrule.province]" value="{{value}}" ng-selected="pagedata.item.matchrule.city==value">{{value}}</option>
																</select>
															</div>
														</div>
														<span class="help-block">为保护个人隐私，个性化菜单将不再支持对地区区分</span>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="card" ng-if="pagedata.item.button.length > 0">
								<div class="btns">
									<a href="javascript:;" ng-click="pagedata.father.splice(pagedata.index,1)"><i class="fa fa-times"></i></a>
								</div>
								<div class="nav-region">
									<div class="first-nav">
										<h3>菜单设置</h3>
										<div class="alert">
											<div class="form-group">
												<label class="control-label col-xs-2">菜单名称</label>
												<div class="col-xs-10">
													<div class="input-group">
														<input type="text" class="form-control" name="" id="title" ng-model="pagedata.activeItem.name"/>
														<div class="input-group-btn">
															<span class="btn btn-primary" ng-click="pagedata.selectEmoji();"><i class="fa fa-github-alt"></i> 添加表情</span>
														</div>
													</div>
												</div>
											</div>
											<div class="form-group" ng-if="!pagedata.activeItem.sub_button || pagedata.activeItem.sub_button.length == 0">
												<label class="control-label col-xs-2">菜单动作</label>
												<div class="col-xs-10 menu-action">
													<span>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="view"  > 链接
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="click"  > 触发关键字
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="scancode_push"  > 扫码
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="scancode_waitmsg"  > 扫码（等待信息）
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="pic_sysphoto"  > 系统拍照发图
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="pic_photo_or_album"  > 拍照或者相册发图
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="pic_weixin"  > 微信相册发图
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="location_select"  > 地理位置
													</label>
													</span>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="media_id"  > 回复素材
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="view_limited"  > 跳转图文
													</label>
													<label class="radio-inline">
														<input type="radio" name="ipt" ng-model="pagedata.activeItem.type" value="miniprogram" ng-click="pagedata.activeItem.url='http://mp.weixin.qq.com';pagedata.activeItem.pagepath='pages/index/index'" > 跳转小程序
													</label>
													<div ng-show="pagedata.activeItem.type == 'view';">
														<hr />
														<div class="input-group">
															<input class="form-control" id="ipt-url" type="text" ng-model="pagedata.activeItem.url"  />
															<div class="input-group-btn">
																<button class="btn btn-primary" id="search" ng-click="choose_link(pagedata.activeItem,'url','allurl')"><i class="fa fa-external-link"></i> 系统链接</button>
															</div>
														</div>
														<span class="help-block">指定点击此菜单时要跳转的链接（注：链接需加http://）</span>
														<span class="help-block"><strong>注意: 由于接口限制. 如果你没有网页oAuth接口权限, 这里输入链接直接进入微站个人中心时将会有缺陷(有可能获得不到当前访问用户的身份信息. 如果没有oAuth接口权限, 建议你使用图文回复的形式来访问个人中心)</strong></span>
													</div>
													<div ng-show="pagedata.activeItem.type == 'miniprogram';">
														<hr />
														<div class="input-group">
															<input class="form-control" id="ipt-url" type="text" ng-model="pagedata.activeItem.appid"  />
															<div class="input-group-btn">
																<button class="btn btn-primary" ng-click="modal_func(pagedata.activeItem,'appid','','wxapp')"  ><i class="fa fa-external-link"></i> 选择小程序</button>
															</div>
														</div>
														<span class="help-block">填写小程序appid</span>
														<div class="input-group">
															<input class="form-control" type="text" ng-model="pagedata.activeItem.pagepath" />
															
														</div>
														<span class="help-block">填写跳转的小程序页面（<red>上面的默认路径不一定准确，具体以微信小程序官方发布小程序默认路径为准！</red>）</span>
													</div>
													<div ng-show="pagedata.activeItem.type == 'media_id' || pagedata.activeItem.type == 'view_limited';">
														<hr />
														<div class="input-group">
															<input class="form-control" id="ipt-url" type="text" ng-model="pagedata.activeItem.media_id"  />
															<div class="input-group-btn">
																<button class="btn btn-primary" id="media_id" ng-click="modal_func(pagedata.activeItem,'media_id','wechat.choose_media','','core','wechat_id='+pagedata.item.wechat_id)"  ><i class="fa fa-external-link"></i> 选择素材</button>
															</div>
														</div>
														<span class="help-block">公众平台的素材id。注意！请选择图文素材！</span>
													</div>
													<div ng-show="pagedata.activeItem.type != 'view' && pagedata.activeItem.type != 'media_id' && pagedata.activeItem.type != 'view_limited' && pagedata.activeItem.type != 'miniprogram'" style="position:relative;">
														<hr />
														<div class="input-group">
															<input class="form-control" id="ipt-forward" type="text" ng-model="pagedata.activeItem.key"  />
															
														</div>
														
														<span class="help-block">指定点击此菜单时要执行的操作, 你可以在这里输入关键字, 那么点击这个菜单时就就相当于发送这个内容至微信系统。如果菜单类型为事件，则用户点击菜单时系统会收到携带该关键词的事件通知（类型为事件时，本项可不填，系统会自动生成）</span>
														<span class="help-block"><strong>这个过程是程序模拟的, 比如这里添加关键字: 优惠券, 那么点击这个菜单是, 微信系统相当于接受了粉丝用户的消息, 内容为"优惠券"</strong></span>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="shop-preview col-xs-12 col-sm-9 col-lg-10">
		<div class="text-center alert alert-warning" style="background:#faebcc">
			<span class="btn btn-primary" id="btn-submit" ng-click="post(pagedata.item,'post')">保存</span>
		</div>

	</div>
</div>
<script>
scope.pagedata.item.matchrule=scope.pagedata.item.matchrule?scope.pagedata.item.matchrule:{}
scope.pagedata.selectEmoji=function(){
	var res=function(emoji){
		scope.pagedata.activeItem.name+=emoji;
	}
	scope.modal_func(res,'','tools.qqemoji','','core');
}
</script>
	